package com.htic.suricata.spreadsheet.dao.impl;

import com.htic.arq.core.model.exception.NotImplementedException;
import com.htic.suricata.api.TestModule;
import com.htic.suricata.api.TestSuite;
import com.htic.suricata.core.dao.TestSuiteDAO;
import com.htic.suricata.core.model.TestModulePopulationAlgorithm;
import com.htic.suricata.core.model.TestSource;
import com.htic.suricata.core.model.TestSourceException;
import com.htic.suricata.spreadsheet.model.TestSourceSpreadSheet;

public class TestSuiteSpreadSheetDAO implements TestSuiteDAO {

	private TestSuiteSpreadSheetPDTDAO testSuitePDT;
	private TestSuiteSpreadSheetODTDAO testSuiteODT;


	public TestSuiteSpreadSheetDAO (){
		this.setTestSuitePDT(new TestSuiteSpreadSheetPDTDAO());
		this.setTestSuiteODT(new TestSuiteSpreadSheetODTDAO());
	}


	@Override
	public TestSuite populateTestSuite(TestSource testSource, TestModule testModule, String testSuiteCode) throws Exception {
		TestSuite testSuite = null;
		String readDataMode	= ((TestSourceSpreadSheet)testSource).getTestModulePopulationAlgorithm().getTestModuleReadDataMode();

		if (readDataMode.equals(TestModulePopulationAlgorithm.TEST_MODULE_READ_DATA_MODE_PDT)) {
			testSuite = testSuitePDT.populateTestSuite(testSource, testModule, testSuiteCode);
		} else if (readDataMode.equals(TestModulePopulationAlgorithm.TEST_MODULE_READ_DATA_MODE_ODT)) {
			testSuite = testSuiteODT.populateTestSuite(testSource, testModule, testSuiteCode);
		} else if (readDataMode.equals(TestModulePopulationAlgorithm.TEST_MODULE_READ_DATA_MODE_AUTO)) {
			throw new NotImplementedException();
		} else  {
			throw new TestSourceException (TestSourceException.TESTPARAMETERS_READDATAMODE_NOTSUPPORTED);
		}

		return testSuite;
	}


	//Getters && Setters
	public TestSuiteSpreadSheetPDTDAO getTestSuitePDT() {
		return testSuitePDT;
	}
	public void setTestSuitePDT(TestSuiteSpreadSheetPDTDAO testSuitePDT) {
		this.testSuitePDT = testSuitePDT;
	}
	public TestSuiteSpreadSheetODTDAO getTestSuiteODT() {
		return testSuiteODT;
	}
	public void setTestSuiteODT(TestSuiteSpreadSheetODTDAO testSuiteODT) {
		this.testSuiteODT = testSuiteODT;
	}
}